﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

using H2.NET.Business;

namespace H2.NET.Web.Pages
{
    public partial class CA : TaskControl
    {
        #region 属性 Public
        public string FORM
        {
            get
            {
                return (Parent as TabMaterial).Status.FORM;
            }
        }

        public string Category
        {
            get
            {
                return (Parent as TabMaterial).Status.Category;
            }            
        }

        public string Action
        {
            get
            {
                return (Parent as TabMaterial).Status.CA;
            }
        }

        private bool IsLoaded
        {
            get
            {
                return ViewState["IsLoaded"] == null ? false : (bool)ViewState["IsLoaded"];
            }
            set { ViewState["IsLoaded"] = value; }
        }

        private bool IsUsed
        {
            get
            {
                //return !(string.IsNullOrEmpty(FORM) || string.IsNullOrEmpty(Action)
                //    || (FORM != "FORM-001" && FORM != "FORM-005" && FORM != "FORM-012" && FORM != "FORM-062" && FORM != "FORM-064" && FORM != "FORM-074"));
                return !string.IsNullOrEmpty(Action);
            }
        }
        #endregion

        #region 事件 页面加载
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Visible = IsUsed;
        }
        #endregion

        #region 方法 InitControls(初始化)
        public void InitControls(mdc_Material mt)
        {
            //如果当前 Tabs 是隐藏的情况，退出
            Visible = IsUsed;
            if (!IsUsed)
            {
                return;
            }

            InitShowHide();

            if (!IsLoaded)
            {
                InitDropDownList();
            }

            Distribute(mt);

            if (TaskAPI.IsAllowSubmit)
            {
                switch (Action)
                {
                    case "C":
                        SetEnable(true, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group, CA_Acct_Assignment_Grp, CA_Cash_Discount
                                      , CA_Dchain_Spec_Status, CA_Easy_Order_Entry, CA_Departure_country, CA_Easy_Order_Entry
                                      , CA_Tax_category, CA_Tax_classification, CA_Minimun_delivery_quantity, CA_Purchasing_Group);
                        SetForeColor(Color.Blue, CA_Tax_Data_L, CA_Easy_Order_Entry_L, CA_Minimun_delivery_quantity_L);
                                               
                        SetDefaultValue();
                        break;
                    case "S":
                        SetEnable(false, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group, CA_Acct_Assignment_Grp
                                       , CA_Cash_Discount, CA_Departure_country, CA_Tax_category, CA_Purchasing_Group
                                       , CA_Tax_classification, CA_Minimun_delivery_quantity, CA_Tax_category
                                       , CA_Dchain_Spec_Status, CA_Easy_Order_Entry);
                                       
                        SetForeColor(Color.Black, CA_Tax_Data_L, CA_Easy_Order_Entry_L, CA_Departure_country_L, CA_Tax_category_L
                                               , CA_Minimun_delivery_quantity_L, CA_Purchasing_Group_L, CA_Tax_classification_L);
                        SetDefaultValue();
                        break;
                    case "E":
                        SetEnable(true, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group
                                      , CA_Acct_Assignment_Grp, CA_Cash_Discount, CA_Dchain_Spec_Status
                                      , CA_Easy_Order_Entry, CA_Departure_country
                                      , CA_Tax_category, CA_Tax_classification, CA_Minimun_delivery_quantity, CA_Purchasing_Group);
                                      
                        SetForeColor(Color.Black, CA_Tax_Data_L, CA_Easy_Order_Entry_L, CA_Tax_category_L, CA_Departure_country_L
                                                , CA_Minimun_delivery_quantity_L, CA_Tax_classification_L, CA_Purchasing_Group_L);

                        //if (TaskAPI.Process == "TW ADVE Code Application" && TaskAPI.Step == "Fill in the request" && (Page as PMDC).Actions.SelectedValue == "Extend")
                        //{
                        //    SetForeColor(Color.Blue, CA_Minimun_delivery_quantity_L);
                        //}
                                                
                        SetDefaultValue();
                        break;
                }
            }
            else
            {
                SetEnable(false, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group, CA_Acct_Assignment_Grp, CA_Cash_Discount, CA_Dchain_Spec_Status, CA_Easy_Order_Entry);
            }
            //魏军添加 控制dropdownlist的enable属性
            string item = "";
            string value = "";
            bool flag_2 = false;
            foreach (Control cr in this.Controls)
            {
                if (cr is DropDownList)
                {
                    DropDownList tb = (DropDownList)cr;
                    if (!tb.Enabled)
                    {

                        try
                        {
                            item = tb.SelectedItem.Text;
                            value = tb.SelectedValue.ToString();
                        }
                        catch (Exception)
                        {
                            flag_2 = true;

                        }
                        if (!flag_2)
                        {
                            tb.Enabled = true;
                            tb.Items.Clear();
                            tb.Items.Add(new ListItem(item, value));
                            tb.SelectedIndex = 0;
                            tb.ForeColor = System.Drawing.Color.DimGray;
                        }
                    }

                }
            }
        }
        #endregion

        #region 方法 Distribute,Collect(分发, 收集值)
        public void Distribute(mdc_Material mt)
        {
            //如果当前 Tabs 是隐藏的情况，退出
            if (!IsUsed)
            {
                return;
            }

            if (   (Parent as TabMaterial).Status.KeyWord == "MM1" 
                && (Parent as TabMaterial).Status.Category == "FINI" 
                && ((Parent as TabMaterial).Status.FORM == "FORM-001"||(Parent as TabMaterial).Status.FORM == "FORM-015" || (Parent as TabMaterial).Status.FORM == "FORM-074" || (Parent as TabMaterial).Status.FORM == "FORM-065-1")
               )
            {
                if ((Parent as TabMaterial).Status.FORM == "FORM-001" || (Parent as TabMaterial).Status.FORM == "FORM-015" || (Parent as TabMaterial).Status.FORM == "FORM-065-1")
                {
                    CA_Easy_Order_Entry.Text = (Page as PMDC).TabMaterial1.Marketing1.MKT_SKU_BPCS_Code.Text;
                }
                else if ((Parent as TabMaterial).Status.FORM == "FORM-074")
                {
                    CA_Easy_Order_Entry.Text = (Page as PMDC).TabMaterial1.Marketing1.MKT_FINI_Code.Text;
                }
            }
            else
            {
                CA_Easy_Order_Entry.Text = mt.CA_Easy_Order_Entry;
            }

            CA_Tax_Data.Text                     = mt.CA_Tax_Data;        
            CA_Gen_Item_Cat_Grp.Text             = mt.CA_Gen_Item_Cat_Grp;   
            CA_Item_Category_Group.Text          = mt.CA_Item_Category_Group;
            CA_Acct_Assignment_Grp.SelectedValue = mt.CA_Acct_Assignment_Grp;
            CA_Cash_Discount.SelectedValue       = mt.CA_Cash_Discount;
            CA_Dchain_Spec_Status.SelectedValue  = mt.CA_Dchain_Spec_Status;
            CA_Tax_classification.Text           = mt.CA_Tax_classification;
            CA_Tax_category.Text                 = mt.CA_Tax_category;
            CA_Departure_country.Text            = mt.CA_Departure_country;
            CA_Minimun_delivery_quantity.Text    = mt.CA_Minimun_delivery_quantity;
            CA_Purchasing_Group.Text             = mt.CA_Purchasing_Group;
            CA_Availability_check.Text           = mt.CA_Availability_check;
            CA_Storage_Location.Text             = mt.CA_Storage_Location;
        }

        public void Collect(ref mdc_Material mt)
        {
            //如果当前 Tabs 是隐藏的情况，退出
            if (!IsUsed)
            {
                return;
            }

            mt.CA_Tax_Data            = CA_Tax_Data.Text;
            mt.CA_Gen_Item_Cat_Grp    = CA_Gen_Item_Cat_Grp.Text;
            mt.CA_Item_Category_Group = CA_Item_Category_Group.Text;
            mt.CA_Acct_Assignment_Grp = CA_Acct_Assignment_Grp.SelectedValue;
            mt.CA_Cash_Discount       = CA_Cash_Discount.SelectedValue;
            mt.CA_Dchain_Spec_Status  = CA_Dchain_Spec_Status.SelectedValue;
            mt.CA_Easy_Order_Entry    = CA_Easy_Order_Entry.Text;
            mt.CA_Tax_classification  = CA_Tax_classification.Text;
            mt.CA_Tax_category        = CA_Tax_category.Text;
            mt.CA_Departure_country   = CA_Departure_country.Text;
            mt.CA_Minimun_delivery_quantity = CA_Minimun_delivery_quantity.Text;
            mt.CA_Purchasing_Group    = CA_Purchasing_Group.Text;
            mt.CA_Storage_Location    = CA_Storage_Location.Text;
            mt.CA_Availability_check  = CA_Availability_check.Text;
        }
        #endregion

        #region 方法 InitDropdownList(初始化下拉框数据源)
        private void InitDropDownList()
        {
            if (!IsLoaded)
            {
                CA_Dchain_Spec_Status.Items.Clear();
                CA_Dchain_Spec_Status.Items.Add(new ListItem("", ""));
                IList<m_DchainSpecStatus> dsss = (m_DchainSpecStatus.status == 1).List<m_DchainSpecStatus>();
                foreach (m_DchainSpecStatus dss in dsss)
                {
                    CA_Dchain_Spec_Status.Items.Add(new ListItem(dss.Dchain_Spec_Status + ", " + dss.Description, dss.Dchain_Spec_Status));
                }
                
                IsLoaded = true;
            }
        }
        #endregion

        #region 方法 InitShowHide(初始化控件显示)
        private void InitShowHide()
        {
            #region 设置禁启用
            SetVisible(false, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group, CA_Acct_Assignment_Grp, CA_Cash_Discount, CA_Dchain_Spec_Status, CA_Easy_Order_Entry
                            , CA_Tax_Data_L, CA_Gen_Item_Cat_Grp_L, CA_Item_Category_Group_L, CA_Acct_Assignment_Grp_L, CA_Cash_Discount_L, CA_Dchain_Spec_Status_L, CA_Easy_Order_Entry_L, CA_Departure_country
                            , CA_Departure_country_L, CA_Tax_category_L, CA_Tax_classification, CA_Tax_classification_L, CA_Minimun_delivery_quantity, CA_Minimun_delivery_quantity_L, CA_Purchasing_Group, CA_Purchasing_Group_L
                            , CA_Tax_category, CA_Storage_Location, CA_Storage_Location_L, CA_Availability_check, CA_Availability_check_L);

            switch (FORM)
            {
                case "FORM-001":
                    SetVisible(true, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group, CA_Acct_Assignment_Grp, CA_Cash_Discount, CA_Dchain_Spec_Status
                                   , CA_Tax_Data_L, CA_Gen_Item_Cat_Grp_L, CA_Item_Category_Group_L, CA_Acct_Assignment_Grp_L, CA_Cash_Discount_L, CA_Dchain_Spec_Status_L, CA_Easy_Order_Entry, CA_Easy_Order_Entry_L);
                    break;

                case "FORM-005":
                case "FORM-012":
                //case "FORM-062":
                case "FORM-064":
                case "FORM-074":
                    CA_Title.Text = "&nbsp;";

                    SetVisible(true, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group, CA_Acct_Assignment_Grp, CA_Cash_Discount, CA_Dchain_Spec_Status
                                   , CA_Tax_Data_L, CA_Gen_Item_Cat_Grp_L, CA_Item_Category_Group_L, CA_Acct_Assignment_Grp_L, CA_Cash_Discount_L, CA_Dchain_Spec_Status_L,
                                     CA_Easy_Order_Entry, CA_Easy_Order_Entry_L);

                    if (FORM == "FORM-064")
                    {
                        SetVisible(false, CA_Easy_Order_Entry, CA_Easy_Order_Entry_L);
                    }

                    break;
                case "FORM-062-1":
                    SetVisible(true, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group, CA_Acct_Assignment_Grp, CA_Cash_Discount, CA_Dchain_Spec_Status
                                  , CA_Tax_Data_L, CA_Gen_Item_Cat_Grp_L, CA_Item_Category_Group_L, CA_Acct_Assignment_Grp_L, CA_Cash_Discount_L, CA_Dchain_Spec_Status_L);
                                  
                    break;
                case "FORM-065-1":
                case "FORM-065-2":
                    if (FORM == "FORM-062" || FORM == "FORM-064" || FORM == "FORM-065-1" || FORM == "FORM-065-2")     //Form-062 HK Fini code  NPL V2.0 100925 && Form-064 HK Trade Code V2.0 100925.xls
                    {
                        CA_Title.Text = "&nbsp;";
                    }

                    SetVisible(true, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group, CA_Acct_Assignment_Grp, CA_Cash_Discount, CA_Dchain_Spec_Status
                                   , CA_Tax_Data_L, CA_Gen_Item_Cat_Grp_L, CA_Item_Category_Group_L, CA_Acct_Assignment_Grp_L, CA_Cash_Discount_L, CA_Dchain_Spec_Status_L,
                                     CA_Easy_Order_Entry, CA_Easy_Order_Entry_L);

                    if (FORM == "FORM-065-2")
                    {
                        SetVisible(false, CA_Gen_Item_Cat_Grp, CA_Gen_Item_Cat_Grp_L, CA_Easy_Order_Entry, CA_Easy_Order_Entry_L, CA_Dchain_Spec_Status, CA_Dchain_Spec_Status_L,
                                          CA_Cash_Discount, CA_Cash_Discount_L);
                    }

                    break;

                case "FORM-031-1":
                    CA_Title.Text = "&nbsp;";
                    SetVisible(true, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group, CA_Acct_Assignment_Grp, CA_Cash_Discount, CA_Dchain_Spec_Status
                                   , CA_Tax_Data_L, CA_Gen_Item_Cat_Grp_L, CA_Item_Category_Group_L, CA_Acct_Assignment_Grp_L, CA_Cash_Discount_L, CA_Dchain_Spec_Status_L);
                    break;
                case "FORM-031-2":
                    CA_Title.Text = "&nbsp;";
                    SetVisible(true, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group, CA_Acct_Assignment_Grp, CA_Cash_Discount, CA_Dchain_Spec_Status
                                   , CA_Tax_Data_L, CA_Gen_Item_Cat_Grp_L, CA_Item_Category_Group_L, CA_Acct_Assignment_Grp_L, CA_Cash_Discount_L, CA_Dchain_Spec_Status_L);
                    break;
                case "FORM-014":
                    CA_Title.Text = "&nbsp;";
                    SetVisible(true, CA_Item_Category_Group, CA_Acct_Assignment_Grp, CA_Cash_Discount, CA_Tax_Data, CA_Item_Category_Group_L, CA_Acct_Assignment_Grp_L, CA_Cash_Discount_L, CA_Tax_Data_L);
                    break;
                case "FORM-067":
                    CA_Title.Text = "&nbsp;";
                    SetVisible(true, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group, CA_Acct_Assignment_Grp, CA_Cash_Discount, CA_Dchain_Spec_Status
                                   , CA_Tax_Data_L, CA_Gen_Item_Cat_Grp_L, CA_Item_Category_Group_L, CA_Acct_Assignment_Grp_L, CA_Cash_Discount_L, CA_Dchain_Spec_Status_L);
                    break;
                case "FORM-015":
                    CA_Title.Text = "&nbsp;";
                    SetVisible(true,CA_Tax_Data,CA_Tax_Data_L,CA_Acct_Assignment_Grp,CA_Acct_Assignment_Grp_L,CA_Item_Category_Group,CA_Item_Category_Group_L
                                   ,CA_Easy_Order_Entry,CA_Easy_Order_Entry_L,CA_Gen_Item_Cat_Grp,CA_Gen_Item_Cat_Grp_L);
                    //SetForeColor(Color.Blue, CA_Easy_Order_Entry_L);               
                    break;
                case "FORM-010":
                    SetVisible(true, CA_Tax_Data, CA_Tax_Data_L, CA_Gen_Item_Cat_Grp, CA_Gen_Item_Cat_Grp_L,CA_Acct_Assignment_Grp, CA_Acct_Assignment_Grp_L, CA_Cash_Discount, CA_Cash_Discount_L, CA_Dchain_Spec_Status, CA_Dchain_Spec_Status_L);
                    break;
                case "FORM-062":
                    CA_Title.Text = "&nbsp;";
                    SetVisible(true, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group, CA_Acct_Assignment_Grp, CA_Cash_Discount, CA_Dchain_Spec_Status
                                   , CA_Tax_Data_L, CA_Gen_Item_Cat_Grp_L, CA_Item_Category_Group_L, CA_Acct_Assignment_Grp_L, CA_Cash_Discount_L, CA_Dchain_Spec_Status_L);
                    break;
                case "FORM-T001":
                    CA_Title.Text = "&nbsp;";
                    SetVisible(true, CA_Departure_country, CA_Departure_country_L, CA_Tax_category, CA_Tax_category_L
                                   , CA_Tax_classification, CA_Tax_classification_L, CA_Minimun_delivery_quantity, CA_Minimun_delivery_quantity_L
                                   , CA_Easy_Order_Entry, CA_Easy_Order_Entry_L, CA_Acct_Assignment_Grp, CA_Acct_Assignment_Grp_L
                                   , CA_Item_Category_Group, CA_Item_Category_Group_L, CA_Purchasing_Group, CA_Purchasing_Group_L, CA_Availability_check, CA_Availability_check_L
                                   , CA_Storage_Location, CA_Storage_Location_L);
                    break;
                case "FORM-T009":
                    CA_Title.Text = "&nbsp;";
                    SetVisible(true, CA_Departure_country, CA_Departure_country_L, CA_Tax_category, CA_Tax_category_L
                                   , CA_Tax_classification, CA_Tax_classification_L, CA_Cash_Discount, CA_Cash_Discount_L
                                   , CA_Acct_Assignment_Grp, CA_Acct_Assignment_Grp_L, CA_Item_Category_Group, CA_Item_Category_Group_L);
                    break;
                case "FORM-T006":
                    CA_Title.Text = "&nbsp;";
                    SetVisible(true, CA_Departure_country, CA_Departure_country_L, CA_Tax_category, CA_Tax_category_L, CA_Tax_category, CA_Tax_category_L, CA_Cash_Discount, CA_Cash_Discount_L
                                   , CA_Acct_Assignment_Grp, CA_Acct_Assignment_Grp_L, CA_Tax_classification, CA_Tax_classification_L);
                    break;
                case "FORM-T010":
                    CA_Title.Text = "&nbsp;";
                    SetVisible(true, CA_Departure_country, CA_Departure_country_L, CA_Tax_category, CA_Tax_category_L, CA_Tax_classification, CA_Tax_classification_L
                                   , CA_Cash_Discount, CA_Cash_Discount_L, CA_Acct_Assignment_Grp, CA_Acct_Assignment_Grp_L, CA_Item_Category_Group, CA_Item_Category_Group_L);
                    break;
                case "FORM-TW-010":
                    CA_Minimun_delivery_quantity_L.Text = "Delivering plant";
                    SetVisible(true, CA_Departure_country, CA_Departure_country_L, CA_Tax_category, CA_Tax_category_L
                                   , CA_Tax_classification, CA_Tax_classification_L, CA_Cash_Discount, CA_Cash_Discount_L, CA_Minimun_delivery_quantity_L, CA_Minimun_delivery_quantity
                                   , CA_Acct_Assignment_Grp, CA_Acct_Assignment_Grp_L, CA_Item_Category_Group, CA_Item_Category_Group_L,CA_Easy_Order_Entry,CA_Easy_Order_Entry_L);

                    break;
                case "FORM-TW-007":
                    //CA_Minimun_delivery_quantity_L.Text = "Delivering plant";
                    SetVisible(true, CA_Departure_country, CA_Departure_country_L, CA_Tax_category, CA_Tax_category_L
                                   , CA_Tax_classification, CA_Tax_classification_L, CA_Cash_Discount, CA_Cash_Discount_L, CA_Minimun_delivery_quantity_L, CA_Minimun_delivery_quantity
                                   , CA_Acct_Assignment_Grp, CA_Acct_Assignment_Grp_L, CA_Item_Category_Group, CA_Item_Category_Group_L, CA_Easy_Order_Entry, CA_Easy_Order_Entry_L
                                   , CA_Dchain_Spec_Status_L, CA_Dchain_Spec_Status, CA_Availability_check_L, CA_Availability_check);

                    break;
            }

            SetToolTip();
            #endregion
        }
        #endregion

        #region 方法 SetDefaultValue(设置默认值, 并禁用输入)
        public void SetDefaultValue()
        {
            CA_Tax_Data.Text                     = "1";
            CA_Gen_Item_Cat_Grp.Text             = "NORM";
            CA_Item_Category_Group.Text          = "NORM";
            //CA_Acct_Assignment_Grp.SelectedValue = "01";
            //CA_Cash_Discount.SelectedValue       = "Y";
            CA_Dchain_Spec_Status.SelectedValue  = "";
            SetEnable(false, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group, CA_Acct_Assignment_Grp, CA_Cash_Discount);
            SetForeColor(Color.Orange, CA_Tax_Data_L, CA_Gen_Item_Cat_Grp_L, CA_Item_Category_Group_L, CA_Acct_Assignment_Grp_L, CA_Cash_Discount_L);

            if (FORM == "FORM-065-1" || FORM == "FORM-065-2")
            {
                //CA_Easy_Order_Entry.Text = "0";
                CA_Acct_Assignment_Grp.SelectedValue = "02";
                CA_Cash_Discount.SelectedValue = "Y";
            }

            //if (FORM == "FORM-074")
            //{
            //    SetEnable(false, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group, CA_Acct_Assignment_Grp, CA_Cash_Discount);
            //    SetForeColor(Color.Orange, CA_Tax_Data_L, CA_Gen_Item_Cat_Grp_L, CA_Item_Category_Group_L, CA_Acct_Assignment_Grp_L, CA_Cash_Discount_L);
            //}
            //else
            //{
                
            //}
            else if (FORM == "FORM-012")
            {
                CA_Cash_Discount.SelectedValue = "Y";
            }

            else if (FORM == "FORM-074")
            {
                CA_Acct_Assignment_Grp.SelectedValue = "01";
                SetEnable(false, CA_Easy_Order_Entry);
            }
            else if (FORM == "FORM-015")
            {
                CA_Acct_Assignment_Grp.SelectedValue = "02";
                
            }
           else if (FORM == "FORM-001")
            {
                CA_Acct_Assignment_Grp.SelectedValue = "01";
                CA_Dchain_Spec_Status.SelectedValue = "";

                SetEnable(false, CA_Dchain_Spec_Status);
                SetForeColor(Color.Orange, CA_Dchain_Spec_Status_L);
            }

           else if (FORM == "FORM-014")
            {
                CA_Tax_Data.Text = "1";
                CA_Gen_Item_Cat_Grp.Text = "NORM";
                CA_Item_Category_Group.Text = "NORM";
                CA_Acct_Assignment_Grp.SelectedValue = "02";
                CA_Cash_Discount.SelectedValue = "Y";
                SetEnable(false, CA_Tax_Data, CA_Gen_Item_Cat_Grp, CA_Item_Category_Group, CA_Acct_Assignment_Grp, CA_Cash_Discount);
                SetForeColor(Color.Orange, CA_Tax_Data_L, CA_Gen_Item_Cat_Grp_L, CA_Item_Category_Group_L, CA_Acct_Assignment_Grp_L, CA_Cash_Discount_L);
            }
            else if (FORM == "FORM-T001")
            {
                CA_Departure_country.Text = "TW";
                CA_Tax_category.Text = "MWST";
                CA_Tax_classification.Text = "1";
                CA_Purchasing_Group.Text = "K20";
                CA_Acct_Assignment_Grp.SelectedValue = "02";
                CA_Item_Category_Group.Text = "NORM";
                CA_Availability_check.Text = "Z1";
                CA_Storage_Location.Text = "0010 0035 0060 0090";
                SetEnable(false, CA_Departure_country, CA_Tax_category, CA_Tax_classification, CA_Purchasing_Group, CA_Item_Category_Group, CA_Availability_check, CA_Storage_Location);
                SetEnable(true, CA_Acct_Assignment_Grp);
                SetForeColor(Color.Orange, CA_Departure_country_L, CA_Tax_category_L, CA_Tax_classification_L, CA_Purchasing_Group_L, CA_Acct_Assignment_Grp_L, CA_Item_Category_Group_L, CA_Availability_check_L, CA_Storage_Location_L);
            }
            else if (FORM == "FORM-T009")
            {
                CA_Departure_country.Text = "TW";
                CA_Tax_category.Text = "MWST";
                CA_Tax_classification.Text = "1";
                CA_Acct_Assignment_Grp.SelectedValue = "11";
                CA_Item_Category_Group.Text = "NORM";
                CA_Cash_Discount.SelectedValue = "N";
                SetEnable(false, CA_Departure_country, CA_Tax_category, CA_Tax_classification, CA_Cash_Discount);
                SetEnable(true, CA_Item_Category_Group, CA_Acct_Assignment_Grp);
                SetForeColor(Color.Orange, CA_Departure_country_L, CA_Tax_category_L, CA_Tax_classification_L, CA_Acct_Assignment_Grp_L, CA_Item_Category_Group_L, CA_Cash_Discount_L);
            }
            else if (FORM == "FORM-T006")
            {
                CA_Departure_country.Text = "TW";
                CA_Tax_category.Text = "MWST";
                CA_Tax_classification.Text = "1";
                CA_Cash_Discount.SelectedValue = "Y";
                CA_Acct_Assignment_Grp.SelectedValue = "01";
                SetEnable(false, CA_Departure_country, CA_Tax_category, CA_Tax_classification, CA_Cash_Discount, CA_Acct_Assignment_Grp);
                SetForeColor(Color.Orange, CA_Departure_country_L, CA_Tax_category_L, CA_Tax_classification_L, CA_Cash_Discount_L, CA_Acct_Assignment_Grp_L);
            }
            else if (FORM == "FORM-TW-010")
            {
                CA_Title.Text = "Technical";
                CA_Departure_country.Text = "TW";
                CA_Tax_category.Text = "MWST";
                CA_Tax_classification.Text = "1";
                CA_Cash_Discount.SelectedValue = "N";
                CA_Acct_Assignment_Grp.SelectedValue = "01";
                CA_Item_Category_Group.Text = "NORM";
                CA_Easy_Order_Entry.Text = "0";
                CA_Minimun_delivery_quantity.Text = "KT2D";
                SetEnable(false, CA_Departure_country,CA_Minimun_delivery_quantity,  CA_Tax_category,CA_Tax_classification, CA_Cash_Discount, CA_Acct_Assignment_Grp, CA_Item_Category_Group,  CA_Easy_Order_Entry);
                SetForeColor(Color.Orange, CA_Minimun_delivery_quantity_L, CA_Departure_country_L, CA_Tax_category_L, CA_Tax_classification_L, CA_Cash_Discount_L, CA_Acct_Assignment_Grp_L, CA_Item_Category_Group_L, CA_Easy_Order_Entry_L);

            }
            else if (FORM == "FORM-TW-007")
            {
                CA_Title.Text = "Technical";
                CA_Availability_check_L.Text = "Minimun order quantity";
                CA_Departure_country.Text = "TW";
                CA_Tax_category.Text = "MWST";
                CA_Tax_classification.Text = "1";
                CA_Cash_Discount.SelectedValue = "Y";
                CA_Acct_Assignment_Grp.SelectedValue = "01";
                CA_Item_Category_Group.Text = "NORM";
                CA_Easy_Order_Entry.Text = "0";
                SetEnable(true, CA_Departure_country, CA_Tax_category, CA_Tax_classification, CA_Cash_Discount, CA_Acct_Assignment_Grp, CA_Item_Category_Group, CA_Easy_Order_Entry);
                SetForeColor(Color.Orange, CA_Departure_country_L, CA_Tax_category_L, CA_Tax_classification_L, CA_Cash_Discount_L, CA_Acct_Assignment_Grp_L, CA_Item_Category_Group_L, CA_Easy_Order_Entry_L);

         
            }
            else if (FORM == "FORM-T010")
            {
                CA_Departure_country.Text = "TW";
                CA_Tax_category.Text = "MWST";
                CA_Tax_classification.Text = "1";
                CA_Cash_Discount.SelectedValue = "N";
                CA_Acct_Assignment_Grp.SelectedValue = "01";
                CA_Item_Category_Group.Text = "NORM";
                SetEnable(false, CA_Departure_country, CA_Tax_category, CA_Tax_classification, CA_Cash_Discount, CA_Acct_Assignment_Grp, CA_Item_Category_Group);
                SetForeColor(Color.Orange, CA_Departure_country_L, CA_Tax_category_L, CA_Tax_classification_L, CA_Cash_Discount_L, CA_Acct_Assignment_Grp_L, CA_Item_Category_Group_L);
            }
            else
            {
                CA_Acct_Assignment_Grp.SelectedValue = "01";
                CA_Cash_Discount.SelectedValue = "N";
            }
        }
        #endregion

        #region 方法 DataValidation(数据验证)
        public List<string> DataValidation(mdc_Material mt, string Sheet)
        {
            List<Regular> regs = new List<Regular>();
            //如果当前 Tabs 是隐藏的情况，退出
            if (!(IsUsed && (Action == "C" || Action == "E")))
            {
                return new List<string>();
            }
            if (FORM == "FORM-015" && (Action == "C"))
            {
                akzo_RegularCheck(ref regs, RegularExp.NotEmpty, CA_Easy_Order_Entry_L, mt.CA_Easy_Order_Entry, Sheet + " Easy_Order_Entry :必填");
            }
            if (FORM == "FORM-T001" && ((Action == "C") || (Action == "E")))
            {
                akzo_RegularCheck(ref regs, RegularExp.Digit3, CA_Minimun_delivery_quantity_L, mt.CA_Minimun_delivery_quantity, Sheet + " Minimun delivery quantity :必填");
            }
            akzo_RegularCheck(ref regs, RegularExp.NotEmpty, CA_Tax_Data_L, mt.CA_Tax_Data, Sheet + "");
            return Validation(regs);
        }
        #endregion

        #region 方法 SetToolTip(设置控件 ToolTip)
        public void SetToolTip()
        {
            switch (Category)
            {
                case "FINI":
                case "TRADE":
                    if (FORM == "FORM-001")
                    {
                        this.CA_Easy_Order_Entry.ToolTip = "同“BPCS Code”";
                        this.CA_Tax_Data.ToolTip = "物料的税分类(默认：1：High tax goods)";
                        this.CA_Gen_Item_Cat_Grp.ToolTip = "普通项目类别组(默认：NORM)";
                        this.CA_Item_Category_Group.ToolTip = "主文件的项目类别组(默认：NORM)";
                        this.CA_Acct_Assignment_Grp.ToolTip = "科目设置组(默认：01：paint)";
                        this.CA_Cash_Discount.ToolTip = "现金折扣(默认Y)";
                        this.CA_Dchain_Spec_Status.ToolTip = "指定分销链的物料状态(如ZO-Order entry block，新建默ZO,可参考)";
                    }

                    if (FORM == "FORM-064" || FORM == "FORM-074")
                    {
                        CA_Tax_Data.ToolTip = "物料的税分类 (默认为1：High tax goods)";
                        CA_Gen_Item_Cat_Grp.ToolTip = "普通项目类别组 (默认为NORM)";
                        CA_Item_Category_Group.ToolTip = "主文件的项目类别组 (默认为NORM)";
                        CA_Acct_Assignment_Grp.ToolTip = "科目设置组";
                        CA_Cash_Discount.ToolTip = "现金折扣 (默认Y)";
                        CA_Dchain_Spec_Status.ToolTip = "指定分销链的物料状态";
                        CA_Easy_Order_Entry.ToolTip = "同“FINI Code”";
                    }
                    if (FORM == "FORM-015")
                    {
                        CA_Tax_Data.ToolTip = "物料的税分类";
                        CA_Gen_Item_Cat_Grp.ToolTip = "普通项目类别组 (默认为NORM)";
                        CA_Item_Category_Group.ToolTip = "主文件的项目类别组 (默认为NORM)";
                        CA_Acct_Assignment_Grp.ToolTip = "科目设置组 (默认为02：Non-paint)";
                        CA_Easy_Order_Entry.ToolTip = "同“Product Code”";
                    }
                    if (FORM.IndexOf("T") ==1)
                    {
                        CA_Departure_country.ToolTip = "發貨國";
                        CA_Tax_category.ToolTip = "默認爲MWST";
                        CA_Tax_classification.ToolTip = "物料的稅分類";
                        CA_Cash_Discount.ToolTip = "現金折扣標誌";
                        CA_Purchasing_Group.ToolTip = "采購組 ";
                        CA_Minimun_delivery_quantity.ToolTip = "最小交貨量";
                        CA_Acct_Assignment_Grp.ToolTip = "科目設置組";
                        CA_Item_Category_Group.ToolTip = "項目類別組 ";
                        CA_Easy_Order_Entry.ToolTip = "同“FINI Code”";
                        CA_Availability_check.ToolTip = "可用性檢查 ";
                        CA_Storage_Location.ToolTip = "需要擴展的倉位";
                        CA_Minimun_delivery_quantity.ToolTip = "交貨工廠(內部/外部)";
                    }
                    if (FORM =="FORM-T001")
                    {
                        CA_Departure_country.ToolTip = "發貨國 默認爲TW";
                        CA_Tax_category.ToolTip = "默認爲MWST";
                        CA_Tax_classification.ToolTip = "物料的稅分類 默認爲1";
                        CA_Purchasing_Group.ToolTip = "采購組 默認爲K20";
                        CA_Minimun_delivery_quantity.ToolTip = "最小交貨量 不超過3位小數";
                        CA_Acct_Assignment_Grp.ToolTip = "科目設置組 默認爲02";
                        CA_Item_Category_Group.ToolTip = "項目類別組 默認爲NORM";
                        CA_Easy_Order_Entry.ToolTip = "同“ADVE Code”";
                        CA_Availability_check.ToolTip = "可用性檢查 默認爲Z1";
                        CA_Storage_Location.ToolTip = "需要擴展的倉位 默認為0010 0035 0060 0090";
                    }
                    if (FORM == "FORM-T006")
                    {
                        CA_Departure_country.ToolTip = "發貨國 默認爲TW";
                        CA_Tax_category.ToolTip = "默認爲MWST";
                        CA_Tax_classification.ToolTip = "物料的稅分類 默認爲1";
                        CA_Acct_Assignment_Grp.ToolTip = "科目設置組, 默認爲01";
                        CA_Cash_Discount.ToolTip = "現金折扣標誌 默認打勾";
                    }
                    if (FORM == "FORM-T010")
                    {
                        CA_Departure_country.ToolTip = "發貨國 默認爲TW";
                        CA_Tax_category.ToolTip = "默認爲MWST";
                        CA_Tax_classification.ToolTip = "物料的稅分類 默認爲1";
                        CA_Acct_Assignment_Grp.ToolTip = "科目設置組, 默認爲01";
                        CA_Cash_Discount.ToolTip = "現金折扣標誌 默認不打勾";
                        CA_Item_Category_Group.ToolTip = "項目類別組 默認為NORM";
                    }
                    if (FORM == "FORM-T009")
                    {
                        CA_Departure_country.ToolTip = "發貨國 默認爲TW";
                        CA_Tax_category.ToolTip = "默認爲MWST";
                        CA_Tax_classification.ToolTip = "物料的稅分類 默認爲1";
                        CA_Acct_Assignment_Grp.ToolTip = "科目設置組, 默認爲02";
                        CA_Cash_Discount.ToolTip = "現金折扣標誌 默認不打勾";
                        CA_Item_Category_Group.ToolTip = "項目類別組 默認為NORM";
                    }
                    break;
            }
        }
        #endregion

        protected void CA_Easy_Order_Entry_TextChanged(object sender, EventArgs e)
        {
            (Page as PMDC).TabMaterial1.Marketing1.MKT_SKU_BPCS_Code.Text = CA_Easy_Order_Entry.Text;
        }
    }
}
